<style scoped>
.center {
  width: 207vh;
  height: 100vh;
  background-image: url("../assets/image.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

h1 {
  font-size: 30px;
  color: black;
}

.logon {
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  /* position: relative;
		overflow: hidden; */
  width: 768px;
  max-width: 100%;
  min-height: 480px;
  margin-top: 20px;
  display: flex;
  background: -webkit-linear-gradient(right, #4284db, #29eac4);
  z-index: 80;
}

.overlaylong {
  border-radius: 10px 0 0 10px;
  width: 50%;
  height: 100%;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlaylongleft {
  border-radius: 0px 10px 10px 0px;
  width: 50%;
  height: 100%;
  background-color: #fff;
  transform: translateX(100%);
  transition: transform 0.6s ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlaylongright {
  border-radius: 10px 0 0 10px;
  width: 50%;
  height: 100%;
  background-color: #fff;
  transform: translateX(0%);
  transition: transform 0.6s ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlaytitle {
  border-radius: 0px 10px 10px 0px;
  width: 50%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlaytitleH2 {
  font-size: 30px;
  color: #fff;
  margin-top: 20px;
}

.overlaytitleP {
  font-size: 15px;
  color: #fff;
  margin-top: 20px;
}

.overlaytitleleft {
  border-radius: 0px 10px 10px 0px;
  width: 50%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(0%);
  transition: transform 0.6s ease-in-out;
}

.overlaytitleright {
  border-radius: 0px 10px 10px 0px;
  width: 50%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(-100%);
  transition: transform 0.6s ease-in-out;
}

.overlaytitle-Signin {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.overlaytitle-Signup {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.buttongohs {
  width: 180px;
  height: 40px;
  border-radius: 50px;
  border: 1px solid #fff;
  color: #fff;
  font-size: 15px;
  text-align: center;
  line-height: 40px;
  margin-top: 40px;
}

.overlaylongH2 {
  font-size: 25px;
  color: black;
  margin-bottom: 3vh;
  /* width: 250px; */
}

.overlaylong-Signin {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.overlaylong-Signup {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

/* input {
  background-color: #eee;
  border: none;
  padding: 12px 15px;
  margin: 10px 0;
  width: 240px;
} */
h3 {
  font-size: 10px;
  margin-top: 10px;
  cursor: pointer;
}

.btn {
  color: #36b4d0;
  background-color: #edf6f5;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 5px;
  width: 70%;
  height: 45px;
  padding: 7px 30px;
  margin: 0 auto 25px;
  border: none;
  display: block;
  position: relative;
  transition: all 0.3s ease;
  margin-top: 3vh;
}

.btn:focus,
.btn:hover {
  color: #fff;
  background-color: #36b4d0;
}

.btn:before,
.btn:after {
  content: "";
  background-color: #36b4d0;
  height: 50%;
  width: 2px;
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 1;
  transition: all 0.3s;
}

.btn:after {
  bottom: auto;
  top: 0;
  left: auto;
  right: 0;
}

.btn:hover:before,
.btn:hover:after {
  height: 100%;
  width: 50%;
  opacity: 0;
}

#background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
</style>
 
<template>
  <div class="center">
    <div id="background"></div>
    <div class="logon animate__animated animate__backInUp">
      <div :class="overlaylong">
        <div class="overlaylong-Signin" v-if="disfiex == 0">
          <h2 class="overlaylongH2">登录</h2>

          <div class="col input-effect">
            <input class="effect-20 style-input" v-model="account" type="text" placeholder="" />
            <label>账号</label>
            <span class="focus-border">
              <i></i>
            </span>
          </div>

          <div class="col input-effect">
            <input class="effect-20 style-input" v-model="operator_name" type="text" placeholder="" />
            <label>用户名</label>
            <span class="focus-border">
              <i></i>
            </span>
          </div>

          <div class="col input-effect">
            <input class="effect-20 style-input " v-model="password" type="password" placeholder="" />
            <label>密码</label>
            <span class="focus-border">
              <i></i>
            </span>
          </div>

          <button class="btn btn-default" @click="login">登录</button>
        </div>
      </div>
      <div :class="overlaytitle">
        <div class="overlaytitle-Signin" v-if="disfiex == 0">
          <img
          :src="require('@/assets/logo.png')"
          alt="Logo"
          style="
            width: 13vh;
            display: inline-block;
            border-radius: 50%;
            margin-top: 1vh;
          "
        />
          <h2 class="overlaytitleH2">你好!</h2>
          <p class="overlaytitleP">欢迎登录理财销售系统~</p>
          <div class="buttongohs">让金融更简单</div>
        </div>
      </div>
    </div>
  </div>
</template>
 

<script>
import "@/css/input-style.css";
import { myLogin } from "@/api/user";
export default {
  name: "login",
  data() {
    return {
      overlaylong: "overlaylong",
      overlaytitle: "overlaytitle",
      disfiex: 0,
      account: "",
      operator_name: "",
      password: "",
    };
  },
  mounted() {
    $("#background").polygonizr();
    $(window).load(function () {
      $(".col input").val("");
      $(".input-effect input").focusout(function () {
        console.log($(this).val());
        if ($(this).val() != "") {
          $(this).addClass("has-content");
        } else {
          $(this).removeClass("has-content");
        }
      });
    });
  },
  methods: {
    login() {
      console.log(this.account, this.operator_name, this.password);
      myLogin({
        operator_name: this.operator_name,
        password: this.password,
        account: this.account,
      })
        .then((res) => {
          console.log(res);
          this.$store.commit("operator/setOperator", {
            operator_name: this.operator_name,
            token: res.data.token,
          }); // TODO: 保存登录信息
          this.$message.success("登录成功");
          this.$router.push({ path: "/home" });
        })
        .catch((err) => {
          console.log(err);
          this.$message.error("登录失败");
        });
    },
  },
};
</script>